package com.xrit.sunnyday.controller;

import com.xrit.sunnyday.entity.Result;
import com.xrit.sunnyday.exception.SunnydayException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class HealExceptionAdvice {
    /**
     * 自定义招出的异常处理
     * @param he
     * @return
     */
    @ExceptionHandler(SunnydayException.class)
    public Result handleSunnydayException(SunnydayException he){
        return new Result(false, he.getMessage());
    }

    /**
     * 所有未知的异常
     * @param he
     * @return
     */
//    @ExceptionHandler(Exception.class)
//    public Result handleException(Exception he){
//        return new Result(false, "发生未知错误，操作失败，请联系管理员");
//    }
}
